package com.hxjc.bankagent.old.config;

import com.cmbc.afw.utils.httpclient.ClientConfig;
import com.hxjc.bankagent.old.merchant.entity.MerchantResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;

/**
 * BankBaseConfig
 *
 * @author yinz
 * @date 2018/5/8
 */

@Configuration
@EnableConfigurationProperties
@PropertySource("cmbc_wg.properties")
public class BankBaseConfig {

    @Autowired
    Environment env;

    @Bean
    public ClientConfig getClientConfig(){
        ClientConfig clientConfig = new ClientConfig();
        clientConfig.setMerchantNum(env.getProperty("merchant.num"));
        clientConfig.setSystemCode(env.getProperty("system.code"));
        clientConfig.setTransCode(env.getProperty("trans.code"));
        clientConfig.setVersion(env.getProperty("version"));
        //请求全路径url
        clientConfig.setPostUrl(env.getProperty("posturl"));
        //返回对象类型
        clientConfig.setResponseClass(MerchantResponse.class);
        //不填默认true
        clientConfig.setSecuritySwitch(Boolean.parseBoolean(env.getProperty("security.switch")));
        clientConfig.setOwnSm2Path(env.getProperty("own.sm2.path"));
        clientConfig.setOwnSm2Pwd(env.getProperty("own.sm2.pwd"));
        clientConfig.setOtherCertPath(env.getProperty("other.cert.path"));
        return clientConfig;
    }
}
